﻿using Microsoft.AspNetCore.Mvc.Filters;

namespace NET6Demo.WebApi.Utility.Filters
{
    /// <summary>
    /// 自定义AsyncResouceFilter
    /// </summary>
    public class CustomAsyncResourceFilterAttribute : Attribute, IAsyncResourceFilter
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        /// <param name="next"></param>
        /// <returns></returns>
        public async Task OnResourceExecutionAsync(ResourceExecutingContext context, ResourceExecutionDelegate next)
        {
            Console.WriteLine("======Before==CustomAsyncResourceFilterAttribute.OnResourceExecutionAsync===========");
            Console.WriteLine("======Before==CustomAsyncResourceFilterAttribute.OnResourceExecutionAsync===========");
            await next.Invoke();

            Console.WriteLine("======After==CustomAsyncResourceFilterAttribute.OnResourceExecutionAsync===========");
            Console.WriteLine("======After==CustomAsyncResourceFilterAttribute.OnResourceExecutionAsync===========");
        }
    }
}
